﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TeamCommunitySolution.Domain.DataLayer.Base;
using TeamCommunitySolution.Services.Security;

namespace TeamCommunitySolution.Services.Factories
{
    public class DomainFactory
    {
        /// <summary>
        /// Creates the message outbox instance.
        /// </summary>
        /// <param name="isRead">if set to <c>true</c> [is read].</param>
        /// <param name="messageContent">Content of the message.</param>
        /// <param name="title">The title.</param>
        /// <param name="dateSent">The date sent.</param>
        /// <param name="userTo">The user to.</param>
        /// <returns>Message Outboxc instance.</returns>
        public static MessageOutbox CreateMessageOutboxInstance(bool isRead, string messageContent, string title, DateTime dateSent, SystemUser userTo, SystemUser userFrom)
        {
            return new MessageOutbox
            {
                IsRead = isRead,
                MessageContent = messageContent,
                Title = title,
                DateSent = dateSent,
                UserTo = userTo,
                UserFrom = userFrom
            };
        }

        /// <summary>
        /// Creates the message inbox instance.
        /// </summary>
        /// <param name="isRead">if set to <c>true</c> [is read].</param>
        /// <param name="messageContent">Content of the message.</param>
        /// <param name="title">The title.</param>
        /// <param name="dateSent">The date sent.</param>
        /// <param name="userFrom">The user from.</param>
        /// <returns>Message inbox instance.</returns>
        public static MessageInbox CreateMessageInboxInstance(bool isRead, string messageContent, string title, DateTime dateSent, SystemUser userFrom, SystemUser userTo)
        {
            return new MessageInbox
                                      {
                                          IsRead = isRead,
                                          MessageContent = messageContent,
                                          Title = title,
                                          DateSent = dateSent,
                                          UserFrom = userFrom,
                                          UserTo = userTo
                                      };
        }

        /// <summary>
        /// Creates the membership instance.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="id">The id of the user.</param>
        /// <returns>Custom membership object.</returns>
        public static SttxMembershipUser CreateMembershipInstance(string email, string id)
        {
            return new SttxMembershipUser { Email = email, Id = id };
        }

        /// <summary>
        /// Creates the system user instance.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="registrationDate">The registration date.</param>
        /// <param name="dateOfBirth">The date of birth.</param>
        /// <param name="lastLogin">The last login.</param>
        /// <param name="lastPasswordChange">The last password change.</param>
        /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
        /// <param name="isEnabled">if set to <c>true</c> [is enabled].</param>
        /// <param name="isLockedOut">if set to <c>true</c> [is locked out].</param>
        /// <param name="password">The password.</param>
        /// <param name="gender">The gender.</param>
        /// <returns>The system user instance.</returns>
        public static SystemUser CreateSystemUserInstance(string username, DateTime registrationDate, DateTime dateOfBirth, DateTime lastLogin, DateTime lastPasswordChange, bool isApproved, bool isEnabled, bool isLockedOut, string password, Gender gender)
        {
            return new SystemUser
                       {
                           Email = username,
                           CreationDate = registrationDate,
                           DateOfBirth = dateOfBirth,
                           LastLoginDate = lastLogin,
                           LastPasswordChanged = lastPasswordChange,
                           IsApproved = isApproved,
                           IsEnabled = isEnabled,
                           IsLockedOut = isLockedOut,
                           Password = password,
                           UserGender = gender
                       };            
        }
    }
}
